package ae.pcfc.etks.online.itworx.ehs.web.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;

@XmlRootElement(name = "fnp")
@XmlAccessorType(XmlAccessType.FIELD)
public class FNP implements Serializable{

	@XmlElement
	@JsonProperty("fnpServices")
	private List<FNPFeesService> fnpServices = new ArrayList<FNPFeesService>();
	private Date expiryDate;
	private String remarks;
	private String userId;
	@JsonIgnore
	private String requestId;
	@JsonIgnore
	private String formattedRequestId;
	@JsonIgnore
	private boolean parametersExists;

	public List<FNPFeesService> getFnpServices() {
		return fnpServices;
	}

	public void setFnpServices(List<FNPFeesService> fnpServices) {
		this.fnpServices = fnpServices;
	}

	public List<String> getServicesId() {
		List<String> servicesId = new ArrayList<String>();

		for (FNPFeesService service : fnpServices) {
			servicesId.add(service.getServiceId());
		}

		return servicesId;
	}

	public Date getExpiryDate() {
		return expiryDate;
	}

	public void setExpiryDate(Date expiryDate) {
		this.expiryDate = expiryDate;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	public String getRequestId() {
		return requestId;
	}

	public void setRequestId(String requestId) {
		this.requestId = requestId;
	}
	public String getFormattedRequestId() {
		return formattedRequestId;
	}

	public void setFormattedRequestId(String formattedRequestId) {
		this.formattedRequestId = formattedRequestId;
	}

	public boolean isParametersExists() {
		if (!fnpServices.isEmpty()) {
			for (FNPFeesService service : fnpServices) {
				if (service.getFnpParameters().size() > 0) {
					return true;
				}
			}
		}
		return false;
	}

	public Map<String, FNPFeesService> listToMap() {
		Map<String, FNPFeesService> mappedList = new HashMap<String, FNPFeesService>();

		for (FNPFeesService service : fnpServices) {
			mappedList.put(service.getServiceId(), service);
		}

		return mappedList;
	}
}
